home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / documents / OpenGL / opengldoc / glspec / pipeline_instrumentation.spec < prev    next >
Encoding:
Text File  |  1996-11-11  |  7.8 KB  |  236 lines

  1. XXX - Not complete yet!!!
  2.  
  3. Name
  4.  
  5.     SGIX_pipeline_instruments
  6.  
  7. Name Strings
  8.  
  9.     GL_SGIX_pipeline_instruments
  10.  
  11. Version
  12.  
  13.     $Date: 1996/04/01 23:23:04 $ $Revision: 1.1 $
  14.  
  15. Number
  16.  
  17.     55
  18.  
  19. Dependencies
  20.  
  21.     None
  22.  
  23. Overview
  24.  
  25.     This extension allows the gathering and return of performance measurements 
  26.     from within the graphics pipeline by adding instrumentation. 
  27.  
  28.     There are two reasons to do this.  The first is as a part of some type of
  29.     fixed-frame-rate load management scheme.  If we know that the pipeline is
  30.     stalled or struggling to process the amount of data we have given it so
  31.     far, we can reduce the level of detail of the remaining objects in the
  32.     current frame or the next frame, or adjust the framebuffer resolution for
  33.     the next frame if we have a video-zoom capability available.  We can call
  34.     this type of instrumentation Load Monitoring.
  35.  
  36.     The second is for performance tuning and debugging of an application. It
  37.     might tell us how many triangles were culled or clipped before being
  38.     rasterized.  We can call this simply Tuning.
  39.  
  40.     Load Monitoring requires that the instrumentation and the access of the
  41.     measurements be efficient, otherwise the instrumentation itself will reduce
  42.     performance more than any load-management scheme could hope to offset.
  43.     Tuning does not have the same requirements. 
  44.  
  45.     While the RE had some experimental Tuning instrumentation implemented in
  46.     software at a great performance penalty,
  47.     Kona is the first machine to provide instrumentation registers that do not 
  48.     affect performance while they are gathering data. 
  49.     The only cost is in accessing them.
  50.     The BEF (Back End (of GE board) Fifo) chip has six registers 
  51.     which are described completely in the BEF spec. 
  52.     The BEF sits in the pipeline just above where rasterization begins.
  53.     We list the registers here for convenience: 
  54.  
  55.     BEF_PERF_COUNTALL,         a free running counter of Tbus cycles
  56.     BEF_PERF_COUNTDRAW,        cycles spent writing drawing information
  57.     BEF_PERF_COUNTLOAD,        cycles spent writing  a texture 
  58.     BEF_PERF_COUNTEMPTY,    cycles spent writing nothing
  59.     BEF_PERF_MAILBOX_TIMESTAMP,    when MAILBOX is written to, COUNTALL is
  60.                 stored here.
  61.     BEF_PERF_MAILBOX,        a seq id may be written to this register
  62.  
  63.     Given the values derived from a register write to store the COUNTALL value
  64.     into the MAILBOX and three writes to zero COUNTDRAW,COUNTLOAD and
  65.     COUNTEMPTY, and one access to get the values back:
  66.  
  67.     cycles spent being host-limited = BEF_PERF_COUNTEMPTY.
  68.     cycles spent being fill-limited = BEF_PERF_COUNTALL - BEF_PERF_COUNTDRAW -
  69.                       BEF_PERF_COUNTLOAD - BEF_PERFCOUNTEMPTY
  70.  
  71.     The BEF1 chip as implemented has a bug, the BEF_PERFCOUNTEMPTY register
  72.     counts all cycles in which we wrote nothing, rather than only the cycles
  73.     in which the destination of the write was ready _and_ we had nothing to
  74.     write to it.  Thus, the system will appear as if it is always
  75.     host/GE-limited if this error is not taken into account. 
  76.  
  77.     The proposed extension adds a call to setup a measurements return buffer,
  78.     similar to FeedbackBuffer but with an asynchrounous behavior to prevent
  79.     filling the pipeline with NOP's while waiting for the data to be returned.
  80.  
  81.     The proposed new procedures and functions and an example of their use is
  82.     given below:
  83.  
  84. New Procedures and Functions
  85.  
  86.     void PipelineInstrumentsBufferSGIX(sizei size, GLfloat *buffer)
  87.  
  88.     GLint StartInstrumentsSGIX(void);
  89.  
  90.     void StopInstrumentsSGIX(void);
  91.  
  92.     GLint PollInstrumentsSGIX(int seq_id);
  93.  
  94.     GLint GetInstrumentsSGIX(int seq_id);
  95.  
  96.     The anticipated usage is as follows:
  97. {
  98.  
  99. #ifdef GL_SGIX_pipeline_instruments
  100.  
  101.    static double buffer[8]; /* HIP has bug, needs to be double-aligned */
  102.    int id0,id1;
  103.    int count0,count1;
  104.    unsigned int *p;
  105.    int i;
  106.    int sim;
  107.  
  108.    if (!strstr((const char *)glGetString(GL_EXTENSIONS),"GL_SGI_pipeline_instrument"))
  109.       ogEnvLog(1, "This test requires the pipeline_instrument extension");
  110.  
  111.    glClearColor(0.0, 0.0, 0.0, 0.0);
  112.    glClear(GL_COLOR_BUFFER_BIT);
  113.  
  114.    glMatrixMode(GL_PROJECTION);
  115.    glOrtho(0.0,2.0,0.0,2.0,1.0,-1.0);
  116.  
  117.    glPipelineInstrumentsBufferSGIX(sizeof(buffer)/sizeof(GLfloat), (GLfloat *) buffer);
  118.  
  119.    glEnable(GL_BEF_INSTRUMENT1_SGIX);
  120.  
  121.    id0 = glStartInstrumentsSGIX();
  122.       /* Try to make this one fill limited */
  123.       for (i = 0; i < 300; i++) drawmesh(2.,2.,1,1,0x00ff00ff);
  124.    glStopInstrumentsSGIX();
  125.  
  126.    id1 = glStartInstrumentsSGIX();
  127.       /* Try to make this one GE/host limited */
  128.       for (i = 0; i < 10; i++) drawmesh(2.,2.,320,240,0xff0000ff);
  129.    glStopInstrumentsSGIX();
  130.  
  131.    while (!glPollInstrumentsSGIX(id0)) ;
  132.    while (!glPollInstrumentsSGIX(id1)) ;
  133.  
  134.    count0 = glGetInstrumentsSGIX(id0);
  135.    count1 = glGetInstrumentsSGIX(id1);
  136.  
  137. #define ID 0
  138. #define COUNT 1
  139. #define COUNTEMPTY 2
  140. #define COUNTDRAW 3
  141. #define COUNTLOAD 4
  142. #define MAILBOX_TIMESTAMP 5
  143. #define COUNTALL 6
  144. #define MAILBOX 7
  145.  
  146.    p = (unsigned int *) buffer;
  147.    if (p[ID] != GL_BEF_INSTRUMENT1_SGIX) 
  148.       ogEnvLog(OG_LFAIL,"FAIL first element of buffer should be GL_BEF_INSTRUMENT1_SGIX\n");
  149.    if (p[COUNT] != 6)
  150.       ogEnvLog(OG_LFAIL,"FAIL second element of buffer should be 6\n");
  151.  
  152.    if (getenv("PRINT_PIPELINE_INSTRUMENTS")){
  153.       fprintf(stderr,"count0 = %d, count1 = %d\n\n",count0,count1);
  154.  
  155.       fprintf(stderr,"p[COUNTALL]          = 0x%08x = %u\n",p[COUNTALL],p[COUNTALL]);
  156.       fprintf(stderr,"p[COUNTDRAW]         = 0x%08x = %u\n",p[COUNTDRAW],p[COUNTDRAW]);
  157.       fprintf(stderr,"p[COUNTLOAD]         = 0x%08x = %u\n",p[COUNTLOAD],p[COUNTLOAD]);
  158.       fprintf(stderr,"p[COUNTEMPTY]        = 0x%08x = %u\n",p[COUNTEMPTY],p[COUNTEMPTY]);
  159.       fprintf(stderr,"p[MAILBOX_TIMESTAMP] = 0x%08x = %u\n",p[MAILBOX_TIMESTAMP],p[MAILBOX_TIMESTAMP]);
  160.  
  161.       fprintf(stderr,"total cycles:        = %d\n",p[COUNTALL]-p[MAILBOX_TIMESTAMP]);
  162.       fprintf(stderr,"host-limited cycles: = %u\n",p[COUNTEMPTY]);
  163.       fprintf(stderr,"fill-limited cycles: = %d\n",
  164.      p[COUNTALL] - p[MAILBOX_TIMESTAMP] - p[COUNTDRAW] - p[COUNTLOAD] - p[COUNTEMPTY]);
  165.       fprintf(stderr,"useful cycles:       = %u\n",p[COUNTDRAW] + p[COUNTLOAD]);
  166.  
  167.       p+= count0;
  168.       fprintf(stderr,"p[COUNTALL]          = 0x%08x = %u\n",p[COUNTALL],p[COUNTALL]);
  169.       fprintf(stderr,"p[COUNTDRAW]         = 0x%08x = %u\n",p[COUNTDRAW],p[COUNTDRAW]);
  170.       fprintf(stderr,"p[COUNTLOAD]         = 0x%08x = %u\n",p[COUNTLOAD],p[COUNTLOAD]);
  171.       fprintf(stderr,"p[COUNTEMPTY]        = 0x%08x = %u\n",p[COUNTEMPTY],p[COUNTEMPTY]);
  172.       fprintf(stderr,"p[MAILBOX_TIMESTAMP] = 0x%08x = %u\n",p[MAILBOX_TIMESTAMP],p[MAILBOX_TIMESTAMP]);
  173.  
  174.       fprintf(stderr,"total cycles:        = %d\n",p[COUNTALL]-p[MAILBOX_TIMESTAMP]);
  175.       fprintf(stderr,"host-limited cycles: = %u\n",p[COUNTEMPTY]);
  176.       fprintf(stderr,"fill-limited cycles: = %d\n",
  177.      p[COUNTALL] - p[MAILBOX_TIMESTAMP] - p[COUNTDRAW] - p[COUNTLOAD] - p[COUNTEMPTY]);
  178.       fprintf(stderr,"useful cycles:      = %u\n",p[COUNTDRAW] + p[COUNTLOAD]);
  179.    }
  180. #endif
  181. }
  182.  
  183. New Tokens
  184.  
  185.     Accepted by the <cap> parameter of Enable, Disable and IsEnabled:
  186.  
  187.        BEF_INSTRUMENT1_SGIX
  188.  
  189.  
  190. Additions to Chapter 2 of the 1.0 Specification (OpenGL Operation)
  191.  
  192.     None
  193.  
  194. Additions to Chapter 3 of the 1.0 Specification (Rasterization)
  195.  
  196.     None
  197.  
  198. Additions to Chapter 4 of the 1.0 Specification (Per-Fragment Operations
  199. and the Frame Buffer)
  200.  
  201.     None
  202.  
  203. Additions to Chapter 5 of the 1.0 Specification (Special Functions)
  204.  
  205.     The following commands are not included in display lists:
  206.  
  207.     PipelineInstrumentsBufferSGIX
  208.     StartInstrumentsSGIX
  209.     StopInstrumentsSGIX
  210.     PollInstrumentsSGIX
  211.     GetInstrumentsSGIX
  212.  
  213. Additions to Chapter 6 of the 1.0 Specification (State and State Requests)
  214.  
  215.     None
  216.  
  217. Additions to the GLX Specification
  218.  
  219.     None
  220.  
  221. GLX Protocol
  222.  
  223.     XXX - not yet complete
  224.  
  225. Errors
  226.  
  227.     XXX - not yet complete
  228.  
  229. New State
  230.  
  231.     None
  232.  
  233. New Implementation Dependent State
  234.  
  235.     None
  236.